package com.huanyang.service;

import jakarta.annotation.Resource;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class ShopService {

    @Resource
    private RedissonClient redissonClient;

    public void addStock() {
        RLock lock = redissonClient.getLock("lock:order:" + Thread.currentThread().getId());
        boolean isLock = lock.tryLock();
        if (!isLock) {
            // 获取锁失败
            return;
        }
        // 获取锁成功
    }
}
